pp108 : bindData() Method

bindData() Method


This method binds XML data to the XGrid. EachrowDataelement results in a row in the XGrid.

Syntax


xgridId.bindData( xmlNode )

Parameters

Parameter Description
xmlNode XML node. Required.


Return Value


No return value.

Remark


The dataNode must conform to a specific structure. Where no end tags are displayed, ".." means zero or more levels.

<topNode>
       ...
       <rowData>
            ...
            <businessObject>
                 ...
                 <businessElements>
        <rowData>
             ...
             <businessObject>
                 ...
                 <businessElements>


The dataNode must have a single top node. TherowDatanodes are repeated for each row. EachrowDatanode must have abusinessObject(this can be the same as therowData). Within the businessObject, zero or morebusinessElementscan be defined. The following is an example of a dataNode:

<data>
    <GetEmployeesResponse xmlns="http://schemas.cordys.com/1.0/demo/northwind">
        <tuple>
            <old>
                <Employees>
                    <EmployeeID>1</EmployeeID>
                    <FirstName>Nancy</FirstName>
                    <LastName>Davolio</LastName>
                </Employees>
            </old>
        </tuple>
        <tuple>
            <old>
                <Employees>
                    <EmployeeID>2</EmployeeID>
                    <FirstName>Andrew</FirstName>
                    <LastName>Fuller</LastName>
                </Employees>
            </old>
        </tuple>
    </GetEmployeesResponse>
</data>


where,<data>is the top node,<tuple>is the rowData,<Employees>the businessObject, and the child elements of<Employees>are the businessElements.

Example


The following example shows how you can use this method to bind data to the XGrid.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html onapplicationready="getData()">
<head>
<title>xpathRowData_businessObject property</title>
<script src="/cordys/wcp/application.js"></script>
<script>
function getData()
{
      //collects data from busdataIsland and bind to xgrid
      bdiEmployees.reset();
    //  bdiEmployees.data.setProperty("SelectionNamespaces", "xmlns:nwd= 'http://schemas.cordys.com/1.0/demo/northwind'");
      employeesGrid.bindData( bdiEmployees.data );
}
</script>

</script>
    <script type="cordys/xml" id="details">  
       <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
	      <SOAP:Body>
		         <GetEmployeesObjects xmlns="http://schemas.cordys.com/DemoWebServices">
		             <fromEmployeeID>1</fromEmployeeID>
		             <toEmployeeID>10</toEmployeeID>
		         </GetEmployeesObjects>
	      </SOAP:Body>
       </SOAP:Envelope>
</script>
</head>
<div  cordysType="wcp.library.data.BusDataIsland" async="false" id="bdiEmployees" automatic="false" request="details.XMLDocument"> </div>
<body scroll="no" leftmargin="0" topmargin="0">
    <div style="width:100%;height:100%;overflow:hidden">
            <div cordysType="wcp.library.ui.XGrid"
                 id="employeesGrid" 
                 xpathRowData = ".//*[local-name()='data']/*[local-name()='GetEmployeesObjectsResponse']/*[local-name()='tuple']";
                 xpathBusinessObject = ".//*[local-name()='Employees']"
                 style="width:95%;height:70%">
                <div id="EmployeeID" ref=".//*[local-name()='EmployeeID']" dataType="integer">EmployeeID</div>
                <div id="FirstName" ref=".//*[local-name()='FirstName']">FirstName</div>
               <div id="LastName" ref=".//*[local-name()='LastName']">LastName</div>
             </div>
    </div>
</body>
</html>

See Also


xgrid, xpathRowData, xpathBusinessObject, ref, refresh()